package com.hopu.v1.controller.admin.exam;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hopu.v1.pojo.common.Delete;
import com.hopu.v1.pojo.common.R;
import com.hopu.v1.pojo.common.Save;
import com.hopu.v1.pojo.common.Update;
import com.hopu.v1.pojo.exam.ExamOptionAnswer;
import com.hopu.v1.service.admin.exam.ExamOptionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: ExamOptionAnswer
 * Description:
 *
 * @Author lh
 * @Create 2024/9/26 10:05
 * @Version 1.0
 */
@RestController
@RequestMapping("examOptionAnswer")
public class ExamOptionAnswerController {
    @Autowired
    private ExamOptionAnswerService examOptionAnswerService;

    /**
     * 新增
     * @param examOptionAnswer
     * @return
     */
    @PostMapping("/add")
    public R add(@Validated(Save.class) @RequestBody ExamOptionAnswer examOptionAnswer) {
        System.out.println(examOptionAnswer);
        examOptionAnswerService.add(examOptionAnswer);
        return R.ok("添加成功");
    }

    /**
     * 修改
     * @param examOptionAnswer
     * @return
     */
    @PostMapping("/update")
    public R update(@Validated(Update.class) @RequestBody ExamOptionAnswer examOptionAnswer) {
        System.out.println(examOptionAnswer);
        examOptionAnswerService.update(examOptionAnswer);
        return R.ok("操作成功");
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @PostMapping("/del")
    public R del(@Validated(Delete.class) Integer id) {
        examOptionAnswerService.del(id);
        return R.ok("操作成功");
    }

    /**
     * 查询
     * @param page
     * @param examOptionAnswer
     * @param endTime
     * @return
     */
    @GetMapping("/selectList")
    public R selectList(Page<ExamOptionAnswer> page, ExamOptionAnswer examOptionAnswer, String endTime) {
        return R.ok(examOptionAnswerService.selectList(page, examOptionAnswer,endTime));
    }
}
